package com.cloud.jucTest;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadLocalTest {
    private static ThreadLocal<Integer> session = new ThreadLocal<Integer>();

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 10; ++i ) {
            executorService.execute(() -> {
                for (int j = 0; j < 10; ++j) {
                    session.set(j);
                    System.out.println(Thread.currentThread().getName() + " value is " + session.get());
                }
            });
        }
        executorService.shutdown();

    }
}
